//
//  BaseTableViewController.swift
//  微博项目
//
//  Created by zhaoyinpeng on 16/3/7.
//  Copyright © 2016年 zhaoyinpeng. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    var userLogin = UserAccount.shareAccout.userLogin
    
    
    //.访客视图属性
    var visitorLoginView: VistorLoginView?
    
    
    //.准备视图层次结构的
    override func loadView() {
        
        //.判读用户是否登录
        if userLogin {
            //.显示用户相关的数据 -> 加载tabbleView
            super.loadView()
        } else {
            
            visitorLoginView = VistorLoginView()
            //            vistorView.backgroundColor = UIColor.redColor()
            
            //.指定代理
            visitorLoginView?.visitorDelegate = self
            
            view = visitorLoginView
            
            
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLognin")
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
            
        }
        
    }
    
    
    //.实现代理方法
    func userWillLognin() {
        print("登录")
        
        let oauth = OAuthViewController()
        
        //.包装在一个导航视图控制器中 进行 modal
        let nav = UINavigationController(rootViewController: oauth)
        
       presentViewController(nav, animated: true, completion: nil)
        
        
        
    }
    
    func userWillRegister() {
        print("注册")
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

 

}
